package repositories;

import java.util.Collection;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import domain.ShoppingCartItemUnit;

@Repository
public interface ShoppingCartItemUnitRepository extends JpaRepository<ShoppingCartItemUnit, Integer> {

	@Query("select s from ShoppingCartItemUnit s where s.customer.id=?1 and s.availableItem.id = ?2")
	ShoppingCartItemUnit findByCustomerAndItemId(int customerId, int availableItemId);
	
	@Query("select s from ShoppingCartItemUnit s where s.customer.id=?1")
	Collection<ShoppingCartItemUnit> findByCustomerId(int customerId);
}
